<html>
  <head>
    <meta charset="utf-8">
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
      crossorigin="anonymous">
    </script>
    
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.css">
    <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.js"></script>
    <style>
      .extra {
	  background-color: #d9d2e9 !important;
      }
      .error {
	  background-color: #cccccc !important;
      }
      .new {
	  background-color: #c9daf8 !important;
      }
      .none {
	  background-color: #f4cccc !important;
      }
      .nosync {
	  background-color: #d9ccd3 !important;
      }
      .old {
	  background-color: #fce5cd !important;
      }
      .pplace {
	  background-color: #d9eaaa !important;
      }
      .same {
	  background-color: #d9ead3 !important;
      }
    </style>
    <title>Status of {{source2}} builds</title>
  </head>
  <body>
    <h1>Status of {{source2}} builds</h1>
    <p>Page updated: {{ date }}</p>
    <table>
      <tr>
	{% for status, counter in mstats.items() -%}
	<td class="{{status}}">
	  {{status}}: {{counter}}
	  {% if status != "total" -%}
          ({{ "{:.2%}".format(counter / mstats.total)}})
	  {% endif -%}
	</td>
	{% endfor -%}
      </tr>
    </table>
    <table>
      <tr>
	{% for status, counter in stats.items() -%}
	<td class="{{status}}">
	  {{status}}: {{counter}}
	  {% if status != "total" -%}
          ({{ "{:.2%}".format(counter / stats.total)}})
	  {% endif -%}
	</td>
	{% endfor -%}
      </tr>
    </table>
    <br>
    <table>
      <tr class="ERROR">
	<td>ERROR</td>
	<td>Package listed by Content Resolver, but no {{product1}} nor {{product2}} build</td>
	</tr>
      <tr class="EXTRA">
	<td>EXTRA</td>
	<td>In {{product2}} but not listed by Content Resolver</td>
	</tr>
      <tr class="NEW">
	<td>NEW</td>
	<td> {{product2}} nvr is newer than {{product1}}</td>
	</tr>
      <tr class="NONE">
	<td>NONE</td>
	<td>There is an {{product1}} build, but no {{product2}} build</td>
	</tr>
      <tr class="NOSYNC">
	<td>NOSYNC</td>
	<td>This package is not synced from {{product1}} to {{product2}}</td>
	</tr>
      <tr class="OLD">
	<td>OLD</td>
	<td>{{product2}} nvr is older than {{product1}}</td>
	</tr>
      <tr class="PPLACE">
	<td>PPLACE</td>
	<td>Package Placeholder</td>
	</tr>
      <tr class="SAME">
	<td>SAME</td>
	<td>{{product2}} and {{product1}} nvr are the same</td>
	</tr>
    </table>
    <h2>Details</h2>
    <table id="comparison" style="compact">
      <thead>
	<tr>
          <th>Package Name</th>
	  <th>Status</th>
	  <th>{{source1}} NVR</th>
	  <th>{{source2}} NVR</th>
      	</tr>
      </thead>
      <tbody>
	{% for pkg_name, pkg_data in results.items() -%}
	<tr>
          <td>{{ pkg_name }}</td>
          <td>
	    {{ pkg_data["status"] }}
	  </td>
          <td>{{ pkg_data["nvr1"] }}</td>
          <td>{{ pkg_data["nvr2"] }}</td>
	</tr>
	{% endfor -%}
      </tbody>
    </table>
    <script>
      $(document).ready(
	  function () {
	      $('#comparison').DataTable(
		  {
		      "paging": false,
		      "createdRow": function( row, data, dataIndex ) {
			  $(row).addClass(data[1]);
		      }
		  }
	      )
	  }
      );
    </script>
  </body>
</html>
